package com.company;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author jrue
 * @version 1.0
 * @date 2020/3/17 19:44
 */
public class Main02 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] proxy = new String[n];
        for (int i = 0; i < proxy.length; i++) {
            proxy[i] = sc.next();
        }
        int m = sc.nextInt();
        ArrayList<String> servers = new ArrayList<>(m);
        for (int i = 0; i < m; i++) {
            servers.add(sc.next());
        }

        int[] indexOfProxy = new int[n];
        for (int i = 0; i < proxy.length; i++) {
            indexOfProxy[i] = servers.indexOf(proxy[i]);
            if (indexOfProxy[i] == -1) {
                System.out.println("0");
                return;
            }
        }
        long count = 0;
        int lastIndex = 0;
        for (int i = 1; i < indexOfProxy.length; i++) {
            if (indexOfProxy[lastIndex] < indexOfProxy[i]) lastIndex = i;
        }
        for (int i = 0; i < servers.size(); i++) {
            String thisServer = servers.get(i);
            if (thisServer.equals(proxy[lastIndex])) {
                count++;
                int innerIndex = lastIndex;
                for (int j = 1; j < indexOfProxy.length; j++) {
                    if (indexOfProxy[lastIndex] < indexOfProxy[j] && innerIndex != j) lastIndex = j;
                }
            }
        }

        System.out.println(count);
    }

}
